# -*-coding: UTF-8 -*-
# @File : RedisUtil .py
# author: huangchen
# Time：2024/1/4
import redis

from config.GlobalVar import G


class RedisUtil:
    def __init__(self, db):
        self.conn = redis.Redis(
            host=G.REDIS_CONFIG["host"],
            port=G.REDIS_CONFIG["port"],
            password=G.REDIS_CONFIG["password"],
            db=db,
            decode_responses=True
    )

    def get_value(self, key):
        value = self.conn.get(key)
        return value if value else None

    def set_value(self, key, value):
        self.conn.set(key, value)